import type { IModalConfig } from "@/components/PageModal/index.vue";
import { editComputer } from "@/api/keeplive/machineRoom/index";
const modalConfig: IModalConfig = {
  pageName: "sys:user",
  dialog: {
    title: "修改用户",
    width: 800,
    appendToBody: true,
  },
  formAction: function (data) {
    // console.log("edit", data);
    console.log("edit", { ...data });
    return new Promise(async (resolve, reject) => {
      try {
        let params = {
          ...data,
        };
        const res = editComputer(params);
        console.log(res);
        resolve({
          code: "00000",
          data: null,
          msg: "编辑成功",
        });
      } catch (error) {
        console.log(error);
        resolve({
          code: "00000",
          data: null,
          msg: "编辑失败",
        });
      }
    });
  },
  formItems: [
    {
      type: "input",
      label: "机房编码",
      prop: "tcrcode",
      attrs: {
        placeholder: "请输入",
        maxlength: 50,
        readonly: true,
      },
    },
    {
      type: "input",
      label: "机房名称",
      prop: "tcrname",
      attrs: {
        placeholder: "请输入",
        maxlength: 50,
      },
    },
    {
      type: "input",
      label: "机房地址",
      prop: "address",
      attrs: {
        placeholder: "请输入",
        maxlength: 50,
      },
    },
    {
      type: "select",
      label: "关联省份",
      prop: "tcraddress",
      attrs: {
        placeholder: "请选择",
        clearable: true,
      },
      options: [],
    },
    // {
    //   type: "radio",
    //   label: "状态",
    //   prop: "status",
    //   options: [
    //     { label: "正常", value: 1 },
    //     { label: "禁用", value: 0 },
    //   ],
    //   initialValue: 1,
    // },
  ],
  formRules: {
    tcrcode: [{ required: true, message: "机房编码不能为空", trigger: "blur" }],
    tcrname: [{ required: true, message: "机房名称不能为空", trigger: "blur" }],
  },
};

export default modalConfig;
